import { Button, Checkbox, Form, Icon, Input, message } from 'antd';
import 'antd/dist/antd.css';
import React from 'react';
import { KEY_STORE_TOKEN } from '../common/constant';
import http from '../common/http';
import './login.css';

class NormalResetPasswordForm extends React.Component {
    constructor(props) {
        super(props)
    }

    handleSubmit = (e) => {
        e.preventDefault()
        this.props.form.validateFields((err, values) => {
            if (!err) {
                if (values.password != values.confirmPassword) {
                    message.error("两次密码不一致")
                    return
                }
                http.post("/api/security/resetPassword", values)
                    .then(res => {
                        message.success("重置成功")
                        this.props.history.push("/login")
                    })
            }
        })
    }

    render() {
        // const { getFieldDecorator } = this.props.form
        return (
            <Form onSubmit={this.handleSubmit} className="login-form">
                {/* <Form.Item>
                    {getFieldDecorator('account', {
                        rules: [{ required: true, message: '请输入账号！' }],
                    })(
                        <Input prefix={<Icon type="user" />} placeholder="账号" />
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('qa1', {
                        rules: [{ required: true, message: '请输入密保一！' }],
                    })(
                        <Input prefix={<Icon type="insurance" />} placeholder="密保：我是谁？" />
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('qa2', {
                        rules: [{ required: true, message: '请输入密保二！' }],
                    })(
                        <Input prefix={<Icon type="insurance" />} placeholder="密保：从哪来？" />
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('qa3', {
                        rules: [{ required: true, message: '请输入密保三！' }],
                    })(
                        <Input prefix={<Icon type="insurance" />} placeholder="密保：到哪去？" />
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('password', {
                        rules: [{ required: true, message: '请输入密码！' }],
                    })(
                        <Input.Password prefix={<Icon type="lock" />} allowClear placeholder="密码" />
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('confirmPassword', {
                        rules: [{ required: true, message: '请输入确认密码！' }],
                    })(
                        <Input.Password prefix={<Icon type="lock" />} allowClear placeholder="确认密码" />
                    )}
                </Form.Item>
                <Form.Item>
                    <Button type="primary" htmlType="submit" className="login-form-button"> <Icon type="lock" /> 重置密码 </Button>
                </Form.Item> */}
            </Form>
        )
    }
}

// const ResetPasswordForm = Form.create({ name: 'reset-password-form' })(NormalResetPasswordForm)
// export default ResetPasswordForm
export default NormalResetPasswordForm